<app:page xmlns:h="http://java.sun.com/jsf/html"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:app="http://java.sun.com/jsf/composite/app"
          xmlns:ds="http://deltaset.org/deltaset-faces"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:c="http://java.sun.com/jsp/jstl/core"
          pageTitle="#{friendMsg['view.title']}">    

    <ds:titlebar title="#{friendMsg['view.title']}">
        <h:button outcome="/secured/friend/form" 
                  value="#{deltasetMessages['deltaset.crud.add']}"
                  styleClass="ds-button"/>
        <h:button outcome="/secured/friend/list" 
                  value="#{deltasetMessages['deltaset.crud.list']}"
                  styleClass="ds-button"/>
    </ds:titlebar>
    <c:set target="#{viewScope}" property="friendModel" value="#{friendBean.loadModel(param.friendId)}"/>
    
    <h:form>
        <ds:fieldset>
            <h:messages styleClass="ui-state-highlight ui-corner-all"/>

            <ds:inputText label="#{friendMsg['userName']}"
                          value="#{viewScope.friendModel.userName}"
                          requiredMessage="#{deltasetMessages['deltaset.crud.required']}"
                          required="true"/>                        
        </ds:fieldset>


        <ui:include src="/secured/community/many-to-one.xhtml">
            <ui:param name="communityModel" value="#{viewScope.friendModel.community}"/>
            <ui:param name="communityTarget" value="viewScope.friendModel.community"/>
        </ui:include>         
        
        <div class="ds-margin-top">
            <h:commandButton action="#{friendBean.save(viewScope.friendModel)}"
                             value="#{deltasetMessages['deltaset.crud.save']}"
                             styleClass="ds-button">               
            </h:commandButton>
            <h:commandButton value="#{deltasetMessages['deltaset.crud.delete']}"
                             action="#{friendBean.delete(viewScope.friendModel)}"
                             onclick="return deltaset.confirm(this)"
                             disabled="#{friendBean.isNew(viewScope.friendModel)}"
                             styleClass="ds-button">               
            </h:commandButton>
        </div>
    </h:form>
</app:page>